package com.bjpowernode.appdata;
import com.bjpowernode.beans.Stu;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
public class MyApp2 {
    public static void main(String[] args) {
        String path = "d:\\stu.data";
        Stu stu;
        try {
            FileInputStream fileInputStream = new FileInputStream(path);
            ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
            //反序列化
            stu = (Stu) objectInputStream.readObject();
            objectInputStream.close();
            fileInputStream.close();
            System.out.println(stu);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
